package com.njegovanobradovic.so.impl;

import org.apache.tapestry5.ioc.annotations.Inject;

import com.njegovanobradovic.core.dao.HibernateDAO;
import com.njegovanobradovic.so.Delete;

public class DeleteImpl<Type> implements Delete<Type> {
	@Inject
	private HibernateDAO dao;
	private Long id;
	private Class<Type> searchForType;

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Class<Type> getSearchForType() {
		return searchForType;
	}
	public void setSearchForType(Class<Type> searchForType) {
		this.searchForType = searchForType;
	}
	public Type execute() {
		try {
			dao.delete(id, getSearchForType());
			System.out.println("Object is deleted");
		} catch (Exception e) {
			System.out.println("Error: " + e);
		}
		return null;
	}
}
